﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClassLibrary.Data;
using System.Data;
using ClassLibrary.Entity;

namespace ClassLibrary.DAO
{
    public class TblTraGopDAO
    {
        private DBService _db = null;
        public TblTraGopDAO(String ConnectionString)
        {
            _db = new DBService(ConnectionString);
        }

        public DataTable InsTraGop(TblTraGop tragop, int mode)
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("TblTraGop_InsUp",
                    new string[] { "@ID", "@NoiDung", "@Mode" },
                    new object[] { tragop.ID, tragop.NoiDung, mode }, CommandType.StoredProcedure);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }

        public DataTable GetTraGop()
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("select * from TblTraGop", false , CommandType.Text);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }

        public DataTable GetTraGop_ById(int ID)
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("select * from TblTraGop where ID = @ID", 
                    new string[]{ "@ID" }, new object[]{ ID }, CommandType.Text);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }

    }
}
